package calendar;

import java.util.Calendar;
/*
    获取和设置日历对象的信息  :
        int get(int field) : 获取指定日历字段信息
            int field : 日期字段
        void set(int field, int value) : 设置日历信息
        void set(int year, int month, int date, int hourOfDay, int minute, int second)
 */
public class CalendarDemo1 {
    public static void main(String[] args) {
        //创建日历对象
        Calendar now = Calendar.getInstance();

        //获取日历信息
        System.out.println("now.get(Calendar.YEAR) = " + now.get(Calendar.YEAR));//2022
        System.out.println("now.get(Calendar.HOUR) = " + now.get(Calendar.HOUR_OF_DAY));//16

        now.set(Calendar.YEAR,1998);
        System.out.println("now.get(Calendar.YEAR) = " + now.get(Calendar.YEAR));//1998


    }
}
